//
//  STTools_IPAPurchaseManger.h
//  togetherPlay
//
//  Created by coder on 2019/1/15.
//  Copyright © 2019 stoneobs.qq.com. All rights reserved.
//


#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
NS_ASSUME_NONNULL_BEGIN
@class STTools_IPAPurchaseModel;
//支付成功回调
typedef void(^STIPAPurchaseInput_stoneobs_handle)(BOOL success,NSString *base64String,NSString *errorString);
//异常回调
typedef void(^STIPAPurchaseUnusual_stoneobs_handle)(NSArray<STTools_IPAPurchaseModel*> *orderArray);
/************内购manger******************/
@interface STTools_IPAPurchaseManger : NSObject
@property(nonatomic, strong) NSMutableArray<STTools_IPAPurchaseModel*>                     *productListArray;/**< 手动赋值产品列表,可以网络赋值 */
@property(nonatomic, copy)   STIPAPurchaseUnusual_stoneobs_handle                               unusualHandle;/**< 异常回调 */
@property(nonatomic, strong,readonly) NSArray<SKPaymentTransaction*>                    *currentUnusualArray;/**< 持有异常回调的订单 */
+ (STTools_IPAPurchaseManger*)manger;


/**
 通过userId 来开始监听 在登录成功之后必须 重新重新绑定，用于将订单和用户绑定

 @param userId userId description
 */
- (void)stoneobs_fun_st_beginMonitorWithUserID:(NSString*)userId;


/**
 购买

 @param productId productId description
 */
- (void)stoneobs_fun_st_beginBuyWithProductId:(NSString*)productId handle:(STIPAPurchaseInput_stoneobs_handle)handle;


//将回执的这条订单标记成以完成
- (void)stoneobs_fun_st_makeOrderCompleteWithReceiptString:(NSString*)receiptString;
@end
/************通用模型******************/
@interface STTools_IPAPurchaseModel : NSObject
@property(nonatomic, strong) NSString                     *receiptString;/**< 购买成功回执 */

@property(nonatomic, strong) NSString                     *productId;/**< 苹果网站的 商品id 一般命名规范 bundleid_获得效益_价格*，eg:xxx_4_6*/
@property(nonatomic, strong) NSString                     *productDesc;/**< 产品描述 */
@property(nonatomic, strong) NSString                     *productPrice;/**< 产品价格 */
@property(nonatomic, strong) NSString                     *productTitle;/**< 产品标题 */

@property(nonatomic, strong) NSString                     *createTime;/**< 创建时间 时间戳*/
@property(nonatomic, strong) NSString                     *onwer_id;/**< 拥有者id，一般是用户id */
@property(nonatomic, assign) BOOL                         isSuccessInput;/**< 是否 已经成功付款并且 赋值给自己的服务器 */

@property(nonatomic, strong) SKPaymentTransaction                     *transaction;/**< <##> */
@end
NS_ASSUME_NONNULL_END
